# 请设计一个装饰器，它可以作用于任何函数上，打印函数执行时间：
import time
def metric(fn):
    def print_time(*args, **kw):
        start_time = time.time()
        result = fn(*args, **kw)
        end_time = time.time()
        print('耗时：{:.8f}s'.format(end_time - start_time))
        return result
    return print_time

@metric
def fn(n):
    sum = 0
    for i in range(n):
        sum += i
    print(sum)
    #return sum

fn(10)